#!/bin/bash
#author by:| leman
#time:| 2020-1-7

echo "before install"
useradd nginx -s /bin/nologin

rpm_install(){
    yum -y install gcc gcc-c++;
    yum -y install pcre-devel openssl openssl-devel zlib zlib-devel;
}
deb_install(){
     apt update;
     apt install gcc c++;
}

echo "get nginx source pacage"
wget http://nginx.org/download/nginx-1.10.3.tar.gz

echo "tar pacage"
tar -xvzf  nginx-1.10.3.tar.gz -C nginx-1.10.3


cd nginx-1.10.3

./configure --prefix=/usr/local/nginx-1.10.3 --with-http_stub_status_module --with-http_ssl_module 
make && make install

echo "start nginx service"

/usr/local/nginx-1.10.3/sbin/nginx
ln -s /data/nginx-1.10.3/ /usr/local/nginx
echo "/usr/local/nginx/sbin/nginx" >>/etc/rc.local

#配置环境变量
touch /etc/profile.d/nginx.sh
echo "export PATH=/usr/local/ngin/sbin:$PATH" >>/etc/profile.d/nginx.sh
source /etc/profile.d/nginx.sh
